<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page import="com.bosch.in.rtp1.ept.constant.LotStatusColumnName"%>
<%@ page import="java.util.List"%>
<%@page import="com.bosch.in.rtp1.ept.constant.CommonConstants"%>
<script type="text/javascript" src="js/lotstatus.js"></script>
<div id="filterHeader" class="ui-jqgrid ui-widget  ui-corner-all">
	<div class = "ui-jqgrid-view">
		<div class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix">
			<a id="minFilterButton" class="ui-jqgrid-titlebar-close HeaderButton" href="javascript:void(0)" style="right: 0px;">
				<span id="minButton" class="ui-icon ui-icon-circle-triangle-n"></span>
			</a>
				<span class="ui-jqgrid-title">Filter Criteria</span>
		</div>
	</div>
</div>
<table id="filterCriteria" width="100%" border="0"  class="box" id="search_box">
	<tbody>
		<tr>
			<td colspan="8">&nbsp;</td>
		</tr>
		<tr>
			<td align="left" width='100px'>
				<input type="checkbox" id="department" name="department" value="EPT"  checked="checked"/>EPT <br>
				<input type="checkbox" id="department" name="department" value="EST1"  checked="checked"/>EST1 <br>
				<input type="checkbox" id="department" name="department" value="EST2"  checked="checked"/>EST2 <br>
			</td>
			<td>
			</td>
			<td>
			</td>
			<td  nowrap="nowrap" valign="top">
				<input type="checkbox" id="prodarea" name="prodarea" value="FAB1" checked="checked"/>FAB1 <br>
				<input type="checkbox" id="prodarea" name="prodarea" value="FAB2" checked="checked"/>FAB2 <br>
			</td>
			<td  width='80px' nowrap="nowrap" style="max-width: 80px;"> 
				<span style="width: 80px;display:inline-block;font-size: 11px;">Hold code</span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			<td width="120px">
				<html:select  name="lotStatusCriteria" property="selectedHCFilter" styleClass="DropDownTextBox" style="width:100%">
					<html:option value="">Select All</html:option>
					<html:optionsCollection name="lotStatusCriteria" property="holdCodeFilters" label="comment" value="patternsInStr"/>
				</html:select>
			</td>
			<td>
			</td>
			<td></td>
		</tr>
		<tr>
			<td  width='105px' align="left" nowrap="nowrap">
				<span style="width: 100px;display:inline-block;font-size: 11px;">Customer name : </span> 
			</td>
			<td width="120px">
				<input  name="customername" id="customername" style="width:100%"/>
			</td>
			<td width="10px">
			</td>
			<td width="300px" nowrap="nowrap">
				<span style="font-size: 11px;">Priority : 
						  1 <input type="checkbox" id="priority" name="priority" value="1" checked="checked"/> &nbsp;&nbsp;
						  2	<input type="checkbox" id="priority" name="priority" value="2" checked="checked"/> &nbsp;&nbsp;
						  3	<input type="checkbox" id="priority" name="priority" value="3" checked="checked"/> &nbsp;&nbsp;
						  4	<input type="checkbox" id="priority" name="priority" value="4" /> &nbsp;&nbsp;
						  5	<input type="checkbox" id="priority" name="priority" value="5" />
				</span> 
			</td>
			<td  width='80px' nowrap="nowrap">  
				<span style="width: 80px;display:inline-block;font-size: 11px;">Hold reason</span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			<td width="120px">
				<input  name="holdreason" id="holdreason" style="width:100%"/>
			</td>
			<td width="10px">
			</td>
			<td>
				<a class="bosch_button_style" href="javascript:searchByFilter();">Show </a>
			</td>
		</tr>
	</tbody>
</table>
<br>
<div id="content">
<table id="s3list"></table>
<div id="s3pager"></div>
<div id="filter" style="margin-left: 30%; display: none">Search</div>

<jsp:useBean id="current" class="java.util.Date" />

<%
	List<String> frzCols = (List<String>) request.getAttribute(CommonConstants.LOT_STATUS_FRZ_COLS);
%>


<script type="text/javascript">
	populateData({
		colNames: [ 
		   			'<%=LotStatusColumnName.LOT_ID%>', '<%=LotStatusColumnName.CURMAIN_QTY%>',
		    		'<%=LotStatusColumnName.PART_ID%>', '<%=LotStatusColumnName.LOT_TYPE%>',
					'<%=LotStatusColumnName.CUSTOMER_NAME%>', '<%=LotStatusColumnName.PRIORITY%>', 
					'<%=LotStatusColumnName.STATE%>', '<%=LotStatusColumnName.WAIT_TIME%>',
					'<%=LotStatusColumnName.X_PLAN%>', '<%=LotStatusColumnName.X_RW%>',
					'<%=LotStatusColumnName.X_RWH%>', '<%=LotStatusColumnName.LOT_COMMENT%>',
					'<%=LotStatusColumnName.HOLD_CODE%>', '<%=LotStatusColumnName.HOLD_REASON%>', 
					'<%=LotStatusColumnName.PRO_AREA%>', '<%=LotStatusColumnName.LOCATION%>', 
					'<%=LotStatusColumnName.CUR_PRCD_ID%>', '<%=LotStatusColumnName.STAGE%>',
					'<%=LotStatusColumnName.RECIPE_ID%>', '<%=LotStatusColumnName.RECIPE_TITLE%>',  
					'<%=LotStatusColumnName.EQP_TYPE%>',
					'<%=LotStatusColumnName.EQUIP_ID%>', '<%=LotStatusColumnName.QUEUE_TIME%>', 
					'<%=LotStatusColumnName.START_TIME%>', '<%=LotStatusColumnName.CR1_SAP%>'
					],
		colModel: [
					{
						name : '<%=LotStatusColumnName.LOT_ID_DB%>',
						index : '<%=LotStatusColumnName.LOT_ID_DB%>',
						width : 55,
						formatter:linkFormatter,
						unformat:linkUnFormatter,
						frozen : <%=frzCols.contains(LotStatusColumnName.LOT_ID) ? "true": "false"%>
					},
					{
						name : '<%=LotStatusColumnName.CURMAIN_QTY_DB%>',
						index : '<%=LotStatusColumnName.CURMAIN_QTY_DB%>',
						width : 24,
						align : "right",
						sortable: true,
						sorttype: 'int',
						frozen : <%=frzCols.contains(LotStatusColumnName.CURMAIN_QTY) ? "true": "false"%>
					},
					{
						name : '<%=LotStatusColumnName.PART_ID_DB%>',
						index : '<%=LotStatusColumnName.PART_ID_DB%>',
						width : 100,
						frozen : <%=frzCols.contains(LotStatusColumnName.PART_ID) ? "true": "false"%>
					},
					{
						name : '<%=LotStatusColumnName.LOT_TYPE_DB%>',
						index : '<%=LotStatusColumnName.LOT_TYPE_DB%>',
						width : 27,
						frozen : <%=frzCols.contains(LotStatusColumnName.LOT_TYPE) ? "true": "false"%>
					},
					{
						name : '<%=LotStatusColumnName.CUSTOMER_NAME_DB%>',
						index : '<%=LotStatusColumnName.CUSTOMER_NAME_DB%>',
						width : 140,
						frozen : <%=frzCols.contains(LotStatusColumnName.CUSTOMER_NAME) ? "true": "false"%>
						
					}, {
						name : '<%=LotStatusColumnName.PRIORITY_DB%>',
						index : '<%=LotStatusColumnName.PRIORITY_DB%>',
						width : 25,
						align : "right",
						sortable: true,
						sorttype: "int",
						frozen : <%=frzCols.contains(LotStatusColumnName.PRIORITY) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.STATE_DB%>',
						index : '<%=LotStatusColumnName.STATE_DB%>',
						width : 30,
						frozen : <%=frzCols.contains(LotStatusColumnName.STATE) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.WAIT_TIME_DB%>',
						index : '<%=LotStatusColumnName.WAIT_TIME_DB%>',
						width : 65,
						align: "right",
						sorttype: "int",
						frozen : <%=frzCols.contains(LotStatusColumnName.WAIT_TIME) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.X_PLAN_DB%>',
						index : '<%=LotStatusColumnName.X_PLAN_DB%>',
						width : 41,
						align: "right",
						sorttype: "float",
						frozen : <%=frzCols.contains(LotStatusColumnName.X_PLAN) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.X_RW_DB%>',
						index : '<%=LotStatusColumnName.X_RW_DB%>',
						width : 35,
						align: "right",
						sorttype: "float",
						frozen : <%=frzCols.contains(LotStatusColumnName.X_RW) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.X_RWH_DB%>',
						index : '<%=LotStatusColumnName.X_RWH_DB%>',
						width : 38,
						align: "right",
						sorttype: "float",
						frozen : <%=frzCols.contains(LotStatusColumnName.X_RWH) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.LOT_COMMENT_DB%>',
						index : '<%=LotStatusColumnName.LOT_COMMENT_DB%>',
						width : 230,
						frozen : <%=frzCols.contains(LotStatusColumnName.LOT_COMMENT) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.HOLD_CODE_DB%>',
						index : '<%=LotStatusColumnName.HOLD_CODE_DB%>',
						width : 38,
						frozen : <%=frzCols.contains(LotStatusColumnName.HOLD_CODE) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.HOLD_REASON_DB%>',
						index : '<%=LotStatusColumnName.HOLD_REASON_DB%>',
						width : 270,
						frozen : <%=frzCols.contains(LotStatusColumnName.HOLD_REASON) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.PRO_AREA_DB%>',
						index : '<%=LotStatusColumnName.PRO_AREA_DB%>',
						width : 27,
						frozen : <%=frzCols.contains(LotStatusColumnName.PRO_AREA) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.LOCATION_DB%>',
						index : '<%=LotStatusColumnName.LOCATION_DB%>',
						width : 60,
						frozen : <%=frzCols.contains(LotStatusColumnName.LOCATION) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.CUR_PRCD_ID_DB%>',
						index : '<%=LotStatusColumnName.CUR_PRCD_ID_DB%>',
						width : 150,
						frozen : <%=frzCols.contains(LotStatusColumnName.CUR_PRCD_ID) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.STAGE_DB%>',
						index : '<%=LotStatusColumnName.STAGE_DB%>',
						width : 70,
						frozen : <%=frzCols.contains(LotStatusColumnName.STAGE) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.RECIPE_ID_DB%>',
						index : '<%=LotStatusColumnName.RECIPE_ID_DB%>',
						width : 55,
						frozen : <%=frzCols.contains(LotStatusColumnName.RECIPE_ID) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.RECIPE_TITLE_DB%>',
						index : '<%=LotStatusColumnName.RECIPE_TITLE_DB%>',
						width : 250,
						frozen : <%=frzCols.contains(LotStatusColumnName.RECIPE_TITLE) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.EQP_TYPE_DB%>',
						index : '<%=LotStatusColumnName.EQP_TYPE_DB%>',
						width : 55,
						frozen : <%=frzCols.contains(LotStatusColumnName.EQP_TYPE) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.EQUIP_ID_DB%>',
						index : '<%=LotStatusColumnName.EQUIP_ID_DB%>',
						width : 55,
						frozen : <%=frzCols.contains(LotStatusColumnName.EQUIP_ID) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.QUEUE_TIME_DB%>',
						index : '<%=LotStatusColumnName.QUEUE_TIME_DB%>',
						width : 117,
						sorttype: 'date',
						formatter:'date',
						align: 'center',
						formatoptions : {srcformat:"d-M-Y H:i:s", newformat: "d-M-Y H:i:s"}, 
						searchoptions:{dataInit:function(el){
							$(el).width('');
							$(el).datepicker(
								{dateFormat:'dd-M-yy',
								 //changeYear: true,
							     //changeMonth: true,
							     showButtonPanel: true,
							     showOn: "button",
							     onSelect: function() {
								     if (this.id.substr(0, 3) === "gs_") {
								        // in case of searching toolbar
								     	setTimeout(function(){
								     		jQuery("#s3list")[0].triggerToolbar();
								        }, 50);
								     } else {
								     	// refresh the filter in case of
								     	// searching dialog
								        $(this).trigger('change');
								     }
							     }    	
								});
								setTimeout(function () {
									$(el).next('button.ui-datepicker-trigger').button({
										text: false,
										icons: {primary: 'ui-icon-calculator'}
									}).find('span.ui-button-text').css('padding', '0.1em'); 
								}, 100);
										
							},
							attr: {size: 13,readonly:false}
						},
						frozen : <%=frzCols.contains(LotStatusColumnName.QUEUE_TIME) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.START_TIME_DB%>',
						index : '<%=LotStatusColumnName.START_TIME_DB%>',
						width : 117,
						sorttype: 'date',
						formatter:'date',
						formatoptions : {srcformat:"d-M-Y H:i:s", newformat: "d-M-Y H:i:s"}, 
						searchoptions:{dataInit:function(el){
							$(el).width('');
							$(el).datepicker(
								{dateFormat:'dd-M-yy',
								 showButtonPanel: true,
								 showOn: "button",
								 onSelect: function() {
								     if (this.id.substr(0, 3) === "gs_") {
								        // in case of searching toolbar
								     	setTimeout(function(){
								     		jQuery("#s3list")[0].triggerToolbar();
								        }, 50);
								     } else {
								     	// refresh the filter in case of
								     	// searching dialog
								        $(this).trigger('change');
								     }
							     }  
								});
								setTimeout(function () {
									$(el).next('button.ui-datepicker-trigger').button({
										text: false,
										icons: {primary: 'ui-icon-calculator'}
									}).find('span.ui-button-text').css('padding', '0.1em'); 
								}, 100);
										
							},
							attr: {size: 13}
						},
						frozen : <%=frzCols.contains(LotStatusColumnName.START_TIME) ? "true": "false"%>
					}, {
						name : '<%=LotStatusColumnName.CR1_SAP_DB%>',
						index : '<%=LotStatusColumnName.CR1_SAP_DB%>',
						width : 85,
						frozen : <%=frzCols.contains(LotStatusColumnName.CR1_SAP) ? "true": "false"%>
					} 
					],
		//defaultSortColumn: '<%=LotStatusColumnName.LOT_ID_DB%>',
		redColorCon: '<%=request.getAttribute(CommonConstants.RED_COLOR_CON)%>',
		yellowColorCon: '<%=request.getAttribute(CommonConstants.YELLOW_COLOR_CON)%>',
		currentDate: '<fmt:formatDate  pattern="dd-MMM-yyyy HH:mm:ss" value="${current}" />'
			}
	);
</script>
</div>
<div class="contextMenu" id="rightClickMenu" style="display:none">
    <ul>
			<li id="CopyRow">
                <span class="ui-icon ui-icon-plus" style="float:left"></span>
                <span style="font-size:11px; font-family:Verdana">Copy Data to Clipboard</span>
            </li>
   </ul>
</div>
<iframe style="width: 0px; height: 0px; visibility: hidden;" src="http://rt-fabigate:8777/iGate/dlz_lotid"></iframe>